﻿/*
* BaseCorps.h
*
* 军团基类
*
* create date: 2014.4.11
* create by: leo
*
*/

#ifndef _BASECORPS_H_
#define _BASECORPS_H_

#include "cocos2d.h"
#include "../Common.h"

#include "../heros/HeroStateListener.h"

class CEmptyCorps;
class CBattleScene;
class CCorpsFormation;

class CBaseCorps : public cocos2d::CCObject, private IBaseHeroStateListener
{
public:
	typedef enum CorpsPos
	{
		FIRST,
		SECOND,
		THIRD,
		FOURTH,
		FIFTH
	} CorpsPos;

public:
	/*
	 * 添加武将到队伍
	 *
	 * hero 要添加的武将
	 */
	virtual void addHero(CBaseHero& hero);
	/*
	 * 从队伍中移除武将
	 *
	 * hero 要移除的武将
	 */
	virtual void removeHero(CBaseHero& hero);
	/*
	 * 移除所有武将
	 */
	virtual void removeAllHero();

	CBaseCorps();
	virtual ~CBaseCorps();

	void preloadRes();

	void setOnDefeatListener(cocos2d::CCObject* callbackObj, cocos2d::SEL_CallFuncO onDefeatCallback);

	void startBattle(CBattleScene& battleScene);

	virtual CBaseHero* getNearestHero(CBaseHero& nearBy);
	virtual CBaseHero* getRandomHero();

	virtual void setCorpsFormation(CCorpsFormation& formation);

    virtual void winGame();

public:
	static CEmptyCorps EmptyCorps;

protected:
	void doNothing(cocos2d::CCObject* obj);

private:
	virtual void onDied(CBaseHero& hero);
	virtual void onPositionChange(CBaseHero& hero);

public:
	CBattleScene* BattleScene;

protected:
//	cocos2d::CCString mName;

	cocos2d::CCArray mHeros; // 包含的武将
	cocos2d::CCObject* mOnDefeatObj; // 战败时回调对象
	cocos2d::SEL_CallFuncO mOnDefeatCallback; // 战败时回调

	CCorpsFormation* mFormation; // 军团阵型

};

#endif // _BASECORPS_H_
